#ifndef BUILDBINDIALOG_H
#define BUILDBINDIALOG_H

//---------------------------------------------------------------------------------------
#include <QDialog>

//---------------------------------------------------------------------------------------
namespace Ui {
class BuildBinDialog;
}
class QFile;
const int DEVTYPE_LEN = 8;
//---------------------------------------------------------------------------------------
class BuildBinDialog : public QDialog
{
    Q_OBJECT

public:
    enum FILE_TYPE{FILE_TYPE_S19, FILE_TYPE_BIN};

    explicit BuildBinDialog(QWidget *parent = 0);
    ~BuildBinDialog();

private slots:
    void on_pushButtonPackage_clicked();

    void on_pushButtonCvtS19ToBIN_clicked();

    void on_pushButtonCombine_clicked();

    void on_pushButtonCut_clicked();

    void on_pushButton_checksum_clicked();

private:
    Ui::BuildBinDialog *ui;

    FILE_TYPE ftype;
    char devtype[DEVTYPE_LEN];
    uint16_t fcrc;
    uint32_t fsize;

    int GetInputFileData(const QString &in, QByteArray &b, uint8_t paddata, int padsize);
    int GetDevTypeFromBinFile(const QString &infile, uint32_t start, char *devtype);
    int DoPackageBin(const QByteArray &b, const QString &out, const char *softver);
    int DoConvertS19ToBin(const QString &in, const QString &out);

    struct CombinePar
    {
        QString filename;
        int offset;
    };
    int DoCombineBin(const QList<CombinePar> &combines, const QString &outfile);
};
//---------------------------------------------------------------------------------------
#endif // BUILDBINDIALOG_H
